<template>
  <div>
    <!-- 添加或修改资产清单表对话框 -->
    <el-dialog v-model="openFlag" title="打印标签" width="50%" append-to-body>

      <div ref="content">
        <print-tag-block :data="row" :model="model" style="margin-bottom: 20px;width: 300px;margin-right: 20px;"></print-tag-block>
      </div>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="printIt">打印</el-button>
        <el-button @click="close">取 消</el-button>
      </div>

    </el-dialog>
  </div>
</template>

<script setup>

import { printDom } from '@/utils/print.js'
import modelApi from '@/views/asset/settings/tag/api.js'
import PrintTagBlock from "@/views/asset/assetItem/PrintTagBlock.vue";

const openFlag = ref(false);
const row = ref({});
const model = ref();
const content = ref();


function getModel() {
  modelApi.getSelect().then((res) => {
    model.value = res;
  })
}

function open(r) {
  row.value = r;
  openFlag.value = true;
  getModel()
}

function close() {
  openFlag.value = false;
}

function printIt() {
  printDom(content.value);

}

defineExpose({
  open
})

</script>

<style scoped lang="scss">
.dialog-footer {
  display: flex;
  justify-content: flex-end;
}

</style>

